修改timesyncd.conf
sudo vi /etc/systemd/timesyncd.conf
修改NTP
参数,修改结果为:
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See timesyncd.conf(5) for details.
[Time]
NTP=ntp2.aliyun.com
#FallbackNTP=ntp.ubuntu.com
#RootDistanceMaxSec=5
#PollIntervalMinSec=32
#PollIntervalMaxSec=2048
设置
sudo timedatectl set-timezone "Asia/Shanghai"
sudo timedatectl set-local-rtc true
sudo timedatectl set-ntp true
apt
国内源备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
修改sources.list
, 文件内容为:
deb https://mirrors.aliyun.com/ubuntu-ports focal main restricted
deb https://mirrors.aliyun.com/ubuntu-ports focal-updates main restricted
deb https://mirrors.aliyun.com/ubuntu-ports focal universe
deb https://mirrors.aliyun.com/ubuntu-ports focal-updates universe
deb https://mirrors.aliyun.com/ubuntu-ports focal multiverse
deb https://mirrors.aliyun.com/ubuntu-ports focal-updates multiverse
deb https://mirrors.aliyun.com/ubuntu-ports focal-backports main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu-ports focal-security main restricted
deb https://mirrors.aliyun.com/ubuntu-ports focal-security universe
deb https://mirrors.aliyun.com/ubuntu-ports focal-security multiverse
swap
创建swapfile
sudo fallocate -l 2G /swapfile
修改swapfile
权限
sudo chmod 600 /swapfile
创建交换空间
sudo mkswap /swapfile
激活swapfile
sudo swapon /swapfile
永久化
修改文件/etc/fstab
,添加以下内容
/swapfile swap swap defaults 0 0
设置交换值
查看
cat /proc/sys/vm/swappiness
临时生效
sudo sysctl vm.swappiness=40
永久生效
在/etc/sysctl.d
中新建配置文件10-swappiness.conf
, 内容为
vm.swappiness=40
停用swap
sudo swapoff /swapfile